/*
REPLICATION code for: 
	"Public Opinion, Rivalry, and the Democratic Peace: 
	Experimental Evidence from South Korea"

AUTHORS:
	Gidong Kim (Stanford University)
	Yu Bin Kim (University of Missouri)
	Dongjin Kwak (Korea University)

JOURNAL:
	International Studies Quarterly

CONTACT (Corresponding Author): 
	Email: gdkim@stanford.edu
	Website: www.gidongkim.com

ORIGIANL ANALYSIS:
	Conducted with STATA 17 (MP) in macOS Sonoma Version 14.0 (2.6 GHz 6-Core Intel Core i7).
*/

************************* START OF REPLICATION *************************

*** Set the working directory
//cd ""

set more off

*********************
*** In Manuscript ***
*********************

* Figure 1
// PDF version (color images)
use "US.dta", replace
cibar strikef_re, over(democ) barcolor(edkblue eltblue) graphopts(graphregion(fcolor(white)) xtitle("The U.S. (2013)") ytitle("Percentage Support") ylabel(0(10)60))
graph save US, replace

use "UK.dta", replace
cibar strikef_re, over(democ) barcolor(edkblue eltblue) graphopts(graphregion(fcolor(white)) xtitle("The U.K. (2013)") ytitle("Percentage Support") ylabel(0(10)60))
graph save UK, replace

use "China.dta", replace
cibar approve_re, over(democracy) barcolor(edkblue eltblue) graphopts(graphregion(fcolor(white)) xtitle("China (2018)") ytitle("Percentage Support") ylabel(0(10)60)) 
graph save China, replace

use "SouthKorea.dta", replace
cibar mil_strike2_re if manipulation==1, over(treatment12) barcolor(edkblue eltblue) graphopts(graphregion(fcolor(white)) xtitle("South Korea (2022)") ytitle("Percentage Support") ylabel(0(10)60)) 
graph save SouthKorea, replace

grc1leg SouthKorea.gph US.gph UK.gph China.gph, rows(1) graphregion(fcolor(white))
graph save Figure1, replace
graph export Figure1.png, replace

// PRINTED version (gray-scaled images)
use "US.dta", replace
cibar strikef_re, over(democ) barcolor(gs5 gs10) graphopts(graphregion(fcolor(white)) xtitle("The U.S. (2013)") ytitle("Percentage Support") ylabel(0(10)60))
graph save US_gray, replace

use "UK.dta", replace
cibar strikef_re, over(democ) barcolor(gs5 gs10) graphopts(graphregion(fcolor(white)) xtitle("The U.K. (2013)") ytitle("Percentage Support") ylabel(0(10)60))
graph save UK_gray, replace

use "China.dta", replace
cibar approve_re, over(democracy) barcolor(gs5 gs10) graphopts(graphregion(fcolor(white)) xtitle("China (2018)") ytitle("Percentage Support") ylabel(0(10)60)) 
graph save China_gray, replace

use "SouthKorea.dta", replace
cibar mil_strike2_re if manipulation==1, over(treatment12) barcolor(gs5 gs10) graphopts(graphregion(fcolor(white)) xtitle("South Korea (2022)") ytitle("Percentage Support") ylabel(0(10)60)) 
graph save SouthKorea_gray, replace

grc1leg SouthKorea_gray.gph US_gray.gph UK_gray.gph China_gray.gph, rows(1) graphregion(fcolor(white))
graph save Figure1_gray, replace
graph export Figure1_gray.png, replace


* Figure 2
ta treatment12_manipulated 
ta treatment34_manipulated 
ta treatment56_manipulated

// PDF version (color images)
cibar mil_strike2_re, over(treatment12_manipulated) barcolor(eltblue edkblue) graphopts(graphregion(fcolor(white)) ytitle(" ") ylabel(0(10)40) legend(size(small) cols(1)))
graph save Figure2_1, replace
cibar mil_strike2_re, over(treatment34_manipulated) barcolor(dkorange maroon) graphopts(graphregion(fcolor(white)) ytitle(" ") ylabel(0(10)40) legend(size(small) cols(1)))
graph save Figure2_2, replace
cibar mil_strike2_re, over(treatment56_manipulated) barcolor(midgreen forest_green) graphopts(graphregion(fcolor(white)) ytitle(" ") ylabel(0(10)40) legend(size(small) cols(1)))
graph save Figure2_3, replace

graph combine Figure2_1.gph Figure2_2.gph Figure2_3.gph, rows(1) graphregion(fcolor(white)) title("Percentage Support", size(midium) color(black))
graph save Figure2, replace
graph export Figure2.png, replace

// PRINTED version (gray-scaled images)
cibar mil_strike2_re, over(treatment12_manipulated) barcolor(gs10 gs5) graphopts(graphregion(fcolor(white)) ytitle(" ") ylabel(0(10)40) legend(size(small) cols(1)))
graph save Figure2_1_gray, replace
cibar mil_strike2_re, over(treatment34_manipulated) barcolor(gs10 gs5) graphopts(graphregion(fcolor(white)) ytitle(" ") ylabel(0(10)40) legend(size(small) cols(1)))
graph save Figure2_2_gray, replace
cibar mil_strike2_re, over(treatment56_manipulated) barcolor(gs10 gs5) graphopts(graphregion(fcolor(white)) ytitle(" ") ylabel(0(10)40) legend(size(small) cols(1)))
graph save Figure2_3_gray, replace

graph combine Figure2_1_gray.gph Figure2_2_gray.gph Figure2_3_gray.gph, rows(1) graphregion(fcolor(white)) title("Percentage Support", size(midium) color(black))
graph save Figure2_gray, replace
graph export Figure2_gray.png, replace



*****************************************************
*** In Online Appendices (NOT in main manuscript) ***
*****************************************************

** Appendix 1
* Table A1
ta female
ta age_group


** Appendix 3
* Table A2
mlogit treatment ideo3 female age educ3 class3 i.region4, base(2)


** Appendix 4
* Table A3
ta manipulate1 if treatment==1
ta manipulate1 if treatment==2
ta manipulate1 if treatment==3
ta manipulate1 if treatment==4
ta manipulate1 if treatment==5
ta manipulate1 if treatment==6

ta manipulate2 if treatment==3
ta manipulate2 if treatment==4
ta manipulate2 if treatment==5
ta manipulate2 if treatment==6

ta manipulation if treatment==1
ta manipulation if treatment==2
ta manipulation if treatment==3
ta manipulation if treatment==4
ta manipulation if treatment==5
ta manipulation if treatment==6

* Table A4
su mil_strike2_re if treatment==1
su mil_strike2_re if treatment==1 & manipulation==1
su mil_strike2_re if treatment==2
su mil_strike2_re if treatment==2 & manipulation==1
su mil_strike2_re if treatment==3
su mil_strike2_re if treatment==3 & manipulation==1
su mil_strike2_re if treatment==4
su mil_strike2_re if treatment==4 & manipulation==1
su mil_strike2_re if treatment==5
su mil_strike2_re if treatment==5 & manipulation==1
su mil_strike2_re if treatment==6
su mil_strike2_re if treatment==6 & manipulation==1

su threat_perception2 if treatment==1
su threat_perception2 if treatment==1 & manipulation==1
su threat_perception2 if treatment==2
su threat_perception2 if treatment==2 & manipulation==1
su threat_perception2 if treatment==3
su threat_perception2 if treatment==3 & manipulation==1
su threat_perception2 if treatment==4
su threat_perception2 if treatment==4 & manipulation==1
su threat_perception2 if treatment==5
su threat_perception2 if treatment==5 & manipulation==1
su threat_perception2 if treatment==6
su threat_perception2 if treatment==6 & manipulation==1

* Table A5
* Model 1
logit manipulation domestic_polint4 female age_group class3
estat ic
* Model 2
logit manipulation inter_polint4 female age_group class3
estat ic
* Model 3
logit manipulation polknow female age_group class3
estat ic
* Model 4
logit manipulation media_use female age_group class3
estat ic
* Model 5
logit manipulation educ3 female age_group class3
estat ic

* Figure A1 (DV = Support for Military Strike)
reg mil_strike2_re i.treatment12##c.domestic_polint4 if manipulation==1
quietly margins treatment12, at(domestic_polint4=(1(1)4))
marginsplot, level(95) title("", color(black)) xtitle("Domestic political interest", color(black)) ytitle("", color(black)) ylabel(0(10)50) xlabel(1(1)4,labsize(small)) legend(size(small) cols(1)) graphregion(fcolor(white)) plot1opts(lcolor(black) mcolor(black) msymbol(circle)) ci1opt(recast(rarea) color(gs10) lwidth(none)) plot2opts(lcolor(black) mcolor(black) msymbol(triangle)) ci2opt(recast(rarea) color(gs5) lwidth(none)) 
graph save figureA1_polint1, replace
	
reg mil_strike2_re i.treatment34##c.domestic_polint4 if manipulation==1
quietly margins treatment34, at(domestic_polint4=(1(1)4))
marginsplot, level(95) title("", color(black)) xtitle("Domestic political interest", color(black)) ytitle("", color(black)) ylabel(0(10)50) xlabel(1(1)4,labsize(small)) legend(size(small) cols(1)) graphregion(fcolor(white)) plot1opts(lcolor(black) mcolor(black) msymbol(circle)) ci1opt(recast(rarea) color(gs10) lwidth(none)) plot2opts(lcolor(black) mcolor(black) msymbol(triangle)) ci2opt(recast(rarea) color(gs5) lwidth(none)) 
graph save figureA1_polint2, replace

reg mil_strike2_re i.treatment56##c.domestic_polint4 if manipulation==1
quietly margins treatment56, at(domestic_polint4=(1(1)4))
marginsplot, level(95) title("", color(black)) xtitle("Domestic political interest", color(black)) ytitle("", color(black)) ylabel(0(10)50) xlabel(1(1)4,labsize(small)) legend(size(small) cols(1)) graphregion(fcolor(white)) plot1opts(lcolor(black) mcolor(black) msymbol(circle)) ci1opt(recast(rarea) color(gs10) lwidth(none)) plot2opts(lcolor(black) mcolor(black) msymbol(triangle)) ci2opt(recast(rarea) color(gs5) lwidth(none)) 
graph save figureA1_polint3, replace
	
gr combine figureA1_polint1.gph figureA1_polint2.gph figureA1_polint3.gph, rows(1) title("Percentage Support", size(midium) color(black)) graphregion(fcolor(white))
graph save figureA1, replace
graph export figureA1.png, replace

* Figure A2 (DV = Support for Military Strike)
reg mil_strike2_re i.treatment12##c.polknow if manipulation==1
quietly margins treatment12, at(polknow=(0(1)4))
marginsplot, level(95) title("", color(black)) xtitle("Political knowledge", color(black)) ytitle("", color(black)) ylabel(0(10)50) xlabel(0(1)4,labsize(small)) legend(size(small) cols(1)) graphregion(fcolor(white)) plot1opts(lcolor(black) mcolor(black) msymbol(circle)) ci1opt(recast(rarea) color(gs10) lwidth(none)) plot2opts(lcolor(black) mcolor(black) msymbol(triangle)) ci2opt(recast(rarea) color(gs5) lwidth(none)) 
graph save figureA2_polknow1, replace	

reg mil_strike2_re i.treatment34##c.polknow if manipulation==1
quietly margins treatment34, at(polknow=(0(1)4))
marginsplot, level(95) title("", color(black)) xtitle("Political knowledge", color(black)) ytitle("", color(black)) ylabel(0(10)50) xlabel(0(1)4,labsize(small)) legend(size(small) cols(1)) graphregion(fcolor(white)) plot1opts(lcolor(black) mcolor(black) msymbol(circle)) ci1opt(recast(rarea) color(gs10) lwidth(none)) plot2opts(lcolor(black) mcolor(black) msymbol(triangle)) ci2opt(recast(rarea) color(gs5) lwidth(none)) 
graph save figureA2_polknow2, replace	

reg mil_strike2_re i.treatment56##c.polknow if manipulation==1
quietly margins treatment56, at(polknow=(0(1)4))
marginsplot, level(95) title("", color(black)) xtitle("Political knowledge", color(black)) ytitle("", color(black)) ylabel(0(10)50) xlabel(0(1)4,labsize(small)) legend(size(small) cols(1)) graphregion(fcolor(white)) plot1opts(lcolor(black) mcolor(black) msymbol(circle)) ci1opt(recast(rarea) color(gs10) lwidth(none)) plot2opts(lcolor(black) mcolor(black) msymbol(triangle)) ci2opt(recast(rarea) color(gs5) lwidth(none)) 
graph save figureA2_polknow3, replace
	
gr combine figureA2_polknow1.gph figureA2_polknow2.gph figureA2_polknow3.gph, rows(1) title("Percentage Support", size(midium) color(black)) graphregion(fcolor(white))
graph save figureA2, replace
graph export figureA2.png, replace

* Figure A3 (DV = Perceptions of threat)
reg threat_perception2 i.treatment12##c.domestic_polint4 if manipulation==1
quietly margins treatment12, at(domestic_polint4=(1(1)4))
marginsplot, level(95) title("", color(black)) xtitle("Domestic political interest", color(black)) ytitle("", color(black)) ylabel(0(20)100) xlabel(1(1)4,labsize(small)) legend(size(small) cols(1)) graphregion(fcolor(white)) plot1opts(lcolor(black) mcolor(black) msymbol(circle)) ci1opt(recast(rarea) color(gs10) lwidth(none)) plot2opts(lcolor(black) mcolor(black) msymbol(triangle)) ci2opt(recast(rarea) color(gs5) lwidth(none)) 
graph save figureA3_polint1, replace

reg threat_perception2 i.treatment34##c.domestic_polint4 if manipulation==1
quietly margins treatment34, at(domestic_polint4=(1(1)4))
marginsplot, level(95) title("", color(black)) xtitle("Domestic political interest", color(black)) ytitle("", color(black)) ylabel(0(20)100) xlabel(1(1)4,labsize(small)) legend(size(small) cols(1)) graphregion(fcolor(white)) plot1opts(lcolor(black) mcolor(black) msymbol(circle)) ci1opt(recast(rarea) color(gs10) lwidth(none)) plot2opts(lcolor(black) mcolor(black) msymbol(triangle)) ci2opt(recast(rarea) color(gs5) lwidth(none)) 
graph save figureA3_polint2, replace	

reg threat_perception2 i.treatment56##c.domestic_polint4 if manipulation==1
quietly margins treatment56, at(domestic_polint4=(1(1)4))
marginsplot, level(95) title("", color(black)) xtitle("Domestic political interest", color(black)) ytitle("", color(black)) ylabel(0(20)100) xlabel(1(1)4,labsize(small)) legend(size(small) cols(1)) graphregion(fcolor(white)) plot1opts(lcolor(black) mcolor(black) msymbol(circle)) ci1opt(recast(rarea) color(gs10) lwidth(none)) plot2opts(lcolor(black) mcolor(black) msymbol(triangle)) ci2opt(recast(rarea) color(gs5) lwidth(none)) 
graph save figureA3_polint3, replace
	
gr combine figureA3_polint1.gph figureA3_polint2.gph figureA3_polint3.gph, rows(1) title("Percentage Threat", size(midium) color(black)) graphregion(fcolor(white))
graph save figureA3, replace
graph export figureA3.png, replace

* Figure A4 (DV = Perceptions of threat)
reg threat_perception2 i.treatment12##c.polknow if manipulation==1
quietly margins treatment12, at(polknow=(0(1)4))
marginsplot, level(95) title("", color(black)) xtitle("Political knowledge", color(black)) ytitle("", color(black)) ylabel(0(20)100) xlabel(0(1)4,labsize(small)) legend(size(small) cols(1)) graphregion(fcolor(white)) plot1opts(lcolor(black) mcolor(black) msymbol(circle)) ci1opt(recast(rarea) color(gs10) lwidth(none)) plot2opts(lcolor(black) mcolor(black) msymbol(triangle)) ci2opt(recast(rarea) color(gs5) lwidth(none)) 
graph save figureA4_polknow1, replace	

reg threat_perception2 i.treatment34##c.polknow if manipulation==1
quietly margins treatment34, at(polknow=(0(1)4))
marginsplot, level(95) title("", color(black)) xtitle("Political knowledge", color(black)) ytitle("", color(black)) ylabel(0(20)100) xlabel(0(1)4,labsize(small)) legend(size(small) cols(1)) graphregion(fcolor(white)) plot1opts(lcolor(black) mcolor(black) msymbol(circle)) ci1opt(recast(rarea) color(gs10) lwidth(none)) plot2opts(lcolor(black) mcolor(black) msymbol(triangle)) ci2opt(recast(rarea) color(gs5) lwidth(none)) 
graph save figureA4_polknow2, replace	

reg threat_perception2 i.treatment56##c.polknow if manipulation==1
quietly margins treatment56, at(polknow=(0(1)4))
marginsplot, level(95) title("", color(black)) xtitle("Political knowledge", color(black)) ytitle("", color(black)) ylabel(0(20)100) xlabel(0(1)4,labsize(small)) legend(size(small) cols(1)) graphregion(fcolor(white)) plot1opts(lcolor(black) mcolor(black) msymbol(circle)) ci1opt(recast(rarea) color(gs10) lwidth(none)) plot2opts(lcolor(black) mcolor(black) msymbol(triangle)) ci2opt(recast(rarea) color(gs5) lwidth(none)) 
graph save figureA4_polknow3, replace
	
gr combine figureA4_polknow1.gph figureA4_polknow2.gph figureA4_polknow3.gph, rows(1) title("Percentage Threat", size(midium) color(black)) graphregion(fcolor(white))
graph save figureA4, replace
graph export figureA4.png, replace


** Appendix 5
* Figure A5
cibar mil_strike2_re, over(treatment) bargap(1) barcolor(eltblue edkblue dkorange maroon midgreen forest_green) graphopts(graphregion(fcolor(white)) ytitle("Percentage Support") ylabel(0(10)40))
graph save FigureA5, replace
graph export FigureA5.png, replace


** Appendix 6
* Figure A6
cibar threat_perception2 if manipulation==1, over(treatment) bargap(1) barcolor(eltblue edkblue dkorange maroon midgreen forest_green) graphopts(graphregion(fcolor(white)) ytitle("Percentage Threat") ylabel(20(20)100)) 
graph save FigureA6, replace
graph export FigureA6.png, replace

* Figure A7
cibar threat_perception2, over(treatment) bargap(1) barcolor(eltblue edkblue dkorange maroon midgreen forest_green) graphopts(graphregion(fcolor(white)) ytitle("Percentage Threat") ylabel(20(20)100)) 
graph save FigureA7, replace
graph export FigureA7.png, replace


** Appendix 7
* Table A6
* Model 1
reg mil_strike2_re i.treatment if manipulation==1
* Model 2
reg mil_strike2_re i.treatment


** Appendix 8
* Figure A8
cibar mil_strike2_re if country_japan_nk == 0, over(treatment34_manipulated) barcolor(dkorange maroon) graphopts(graphregion(fcolor(white)) ytitle(" ") ylabel(0(10)50) legend(size(small) cols(1)) title("Manipulated sample", size(small) color(black)))
graph save FigureA8_1, replace

cibar mil_strike2_re if country_japan_nk == 0, over(treatment34) barcolor(dkorange maroon) graphopts(graphregion(fcolor(white)) ytitle(" ") ylabel(0(10)50) legend(size(small) cols(1)) title("Total sample", size(small) color(black)))
graph save FigureA8_2, replace

graph combine FigureA8_1.gph FigureA8_2.gph, rows(1) title("Percentage Threat", size(midium) color(black)) graphregion(fcolor(white))
graph save FigureA8, replace
graph export FigureA8.png, replace
************************* END OF REPLICATION *************************

